<?php
class TDataTablePromocaoContrato extends TDataTable
{
    public function __construct($usuario,$pfcid, $options = NULL)
    {
        $criterio = array();		
		$model  = new ViewContratosPromocao();	
		$key = 'contratoid';
		
		if (is_null($options)){
		    $options= array('editClass'=>'detalhes','editHeader'=>'candidatos','checkColumn'=>FALSE,'editLink'=>'pesquisarCandidato.php?id=');
		} 
				
		$criterio['precondicao'] = " ativo IS TRUE and  statusid = ".Status::Contrato_CadastroConfirmado;
		
		if ($pfcid == PerfilComportamental::Orgao)
			$criterio['precondicao'] .= ' AND ( contratoid in (SELECT contratoid FROM contratos WHERE orgaoid ='.$usuario->orgaoid.'))';
				
		if ($pfcid == PerfilComportamental::NucleoGestor)
			$criterio['precondicao'] .= ' AND ( contratoid in (SELECT contratoid FROM contratos WHERE orgaoid ='.$usuario->orgaoid.'))';
		
		if ($pfcid == PerfilComportamental::Empresa)
			$criterio['precondicao'] .= ' AND ( contratoid in (SELECT contratoid FROM contratos WHERE empresaid ='.$usuario->empresaid.'))';
				
		parent::__construct($model,$key,$criterio,$options);
		$this->addColumnsData( array(
									'contratoid', 
									'empresa', 
									array('name'=> 'numerosiof','header'=>'numero siof'),
									array('name'=> 'numeroorgao','header'=>'NUMERO DO ORGAO'), 
									'orgao',
									array('name'=>'tipocontrato','header'=>'TIPO DO CONTRATO'),
									'aditivo'
							  ));
		$this->addFiltersCombo(array('empresa', 'orgao', 'tipocontrato','aditivo'));		
    }    
}
